﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Threading;
using System.Net;
using System.Net.Sockets;


namespace udp_camera_client
{
    //client sends images to server, fuck you
    public class UdpImageClient
    {
        private int port;
        private string hostname;
        ASCIIEncoding ascii;

        public UdpImageClient(string hostname, int port)
        {
            this.port = port;
            this.hostname = hostname;
        }

        public void sendingPart()
        {
            ascii = new ASCIIEncoding();
            byte[] data = new byte[500];
            UdpClient server = new UdpClient(this.hostname, this.port);
            IPEndPoint send = new IPEndPoint(IPAddress.Any, 0);

            while (true)
            {
                string words = Console.ReadLine();

                data = ascii.GetBytes(words);
                server.Send(data, data.Length);
            }
        }
    }

    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            UdpImageClient udpServer = new UdpImageClient("127.0.0.1",5000);
            Thread udpServerThread = new Thread(new ThreadStart(udpServer.sendingPart));
            udpServerThread.Start();
            for (; ; ) ;
        }
    }
}
